package org.firebug.metadata.micro.controller;

import org.firebug.metadata.client.feign.DictionaryFeign;
import org.firebug.metadata.client.vo.DictionaryVO;
import org.firebug.metadata.micro.service.DictionaryService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 字典服务
 */
@RestController
@RequestMapping(value= "/dictionary")
public class DictionaryController implements DictionaryFeign {
    @Resource
    private DictionaryService dictionaryService;

    @RequestMapping(value = "/query/{code}", method = {RequestMethod.GET})
    public DictionaryVO query(@PathVariable String code) {
        return dictionaryService.queryByCode(code);
    }

    @RequestMapping(value = "/list/{code}", method = {RequestMethod.GET})
    public List<DictionaryVO> list(@PathVariable("code") String code) {
        return dictionaryService.listByPcode(code);
    }

    @RequestMapping(value = "/list/{code}/{sector}", method = {RequestMethod.GET})
    public List<DictionaryVO> list(@PathVariable("code") String code, @PathVariable(value = "sector") int sector) {
        return dictionaryService.listByPcodeSector(code, sector);
    }
}